package com.conero.yangsu.service;

import com.conero.yangsu.entity.ModuleEntity;
import com.conero.yangsu.mapper.FieldMapper;
import com.conero.yangsu.mapper.ModuleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class ModuleService {
    @Autowired
    private ModuleMapper moduleMapper;
    @Autowired
    private FieldMapper fieldMapper;

    public HashMap<String, Object> getConfigByModule(String module) {
        HashMap<String, Object> hashMap = new HashMap<String, Object>();
        ModuleEntity moduleEntity = moduleMapper.findByModule(module);
        if (moduleEntity == null) {
            return null;
        }

        hashMap.put("module", moduleEntity);
        hashMap.put("field", fieldMapper.findByMid(moduleEntity.getId()));

        return hashMap;
    }
}
